/*
 * Copyright (C) 2007 Evan Long    longx223 (at) umn (dot) edu
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.

 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 */

/**
 * @file   image_proc.h
 * @author Evan Long
 * 
 * @brief  Definition of various image processing functions.
 * 
 * 
 */

#ifndef IMAGE_PROC_H
#define IMAGE_PROC_H

/**
 *Minimum threshold of the point the laser pointer creates
 */
#define BRIGHTEST_THRESHOLD 755

/**
 * Defines a point that exists in a 2D space.
 *
 * @param x Coordinate in the X plane.
 * @param y Coordinate in the Y place.
 */
typedef struct point
{
  int x;
  int y;
} point_t;


/**
 * Defines a pixel for a 24 bit image composed of three color channels.
 *
 * @param red Byte for red color channel
 * @param blue Byte for blue color channel
 * @param green Byte for green color channel
 */
typedef struct pixel_24RGB
{
  unsigned char red;
  unsigned char blue;
  unsigned char green;
} pixel_24RGB_t;

/** 
 * Finds the brightest pixel that is greater than BRIGHTEST_THRESHOLD. It 
 * returns once it has found one. Pixel brightness is calculated by summing up
 * all three color channels.
 * 
 * @param image Pointer to a buffer of a 24 bit color image. 
 * @param width Width of image in pixels.
 * @param height Height of image in pixels. 
 * 
 * @return Point of the brightest pixel.
 */
point_t find_brightest_point(unsigned char* image, int width, int height);

/** 
 * Utility function that will save an image to a file in the PPM format. 
 * 
 * @param image Pointer to a 24 bit color image.
 * @param width Width of image in pixels.
 * @param height Height of image in pixels.
 * @param filename Name of file to save the image to.
 */
void save_image(unsigned char* image, int width, int height, char* filename);

#endif
